import { createPinia } from "pinia";
import type { App } from "vue";
import { createPersistedState } from "pinia-plugin-persistedstate";

// 实例
const store = createPinia();

// 配置持久化
store.use(
  createPersistedState({
    key: (id) => `__APP__${id}__`.toUpperCase(),
  })
);

/**
 * 初始化 Pinia
 */
const initStore = (app: App<Element>) => {
  return app.use(store);
};

export { store, initStore };
